@extends('layouts.base')

@section('title', '报单')

@section('admin-style')
	<link rel="stylesheet" href="{{ asset('/assets/plugins/dropify/dist/css/dropify.min.css') }}">
@stop

@section('content')
<div class="container-fluid">
	<!-- ============================================================== -->
	<!-- Bread crumb and right sidebar toggle -->
	<!-- ============================================================== -->
	<div class="row page-titles">
	    <div class="col-md-5 align-self-center">
	        <h3 class="text-themecolor">报单--编辑</h3>
	    </div>
	    <div class="col-md-7 align-self-center">
	        <ol class="breadcrumb">
	            <li class="breadcrumb-item"><a href="javascript:void(0)">首页</a></li>
	            <li class="breadcrumb-item">报单管理</li>
	            <li class="breadcrumb-item active">报单编辑</li>
	        </ol>
	    </div>
	</div>
	<div class="row">
	    <div class="col-lg-12">
	        <div class="card">
            	<div class="card-header bg-success">
                    <h4 class="m-b-0 text-white">编辑</h4>
                </div>
                <div class="card-body"></div>
                <div class="card-body">                  
                        
                    	<div class="form-body">
	                        <div class="form-group row">
	                            <label class="control-label text-right col-md-2" for="">商户姓名：</label>
	                            <div class="col-md-7">
	                                <span>{{ optional($jd_info->merchant)->name }}</span>
	                            </div>
	                        </div>  
	                        <div class="form-group row">
	                            <label class="control-label text-right col-md-2" for="">手机号：</label>
	                            <div class="col-md-7">
                                    <span>{{ optional($jd_info->merchant)->phone }}</span>
                                </div>
	                        </div> 
                            <div class="form-group row">
                                <label class="control-label text-right col-md-2" for="">商户名称：</label>
                                <div class="col-md-7">
                                    <span>{{ $jd_info->seller_name }}</span>
                                </div>
                            </div>  
                            <div class="form-group row">
                                <label class="control-label text-right col-md-2" for="">商户简称：</label>
                                <div class="col-md-7">
                                    <span>{{ $jd_info->seller_short }}</span>
                                </div>
                            </div> 
                            <div class="form-group row">
                                <label class="control-label text-right col-md-2" for="">联系人姓名：</label>
                                <div class="col-md-7">
                                    <span>{{ $jd_info->person_name }}</span>
                                </div>
                            </div>  
                            <div class="form-group row">
                                <label class="control-label text-right col-md-2" for="">联系人电话：</label>
                                <div class="col-md-7">
                                    <span>{{ $jd_info->person_phone }}</span>
                                </div>
                            </div> 
                            <div class="form-group row">
                                <label class="control-label text-right col-md-2" for="">联系人身份证号：</label>
                                <div class="col-md-7">
                                    <span>{{ $jd_info->person_identity }}</span>
                                </div>
                            </div>  
                            <div class="form-group row">
                                <label class="control-label text-right col-md-2" for="">结算卡号：</label>
                                <div class="col-md-7">
                                    <span>{{ $jd_info->bank_number }}</span>
                                </div>
                            </div> 
                            <div class="form-group row">
                                <label class="control-label text-right col-md-2" for="">开卡银行：</label>
                                <div class="col-md-7">
                                    <span>{{ $jd_info->bank }}</span>
                                </div>
                            </div>  
                            <div class="form-group row">
                                <label class="control-label text-right col-md-2" for="">开卡银行支行：</label>
                                <div class="col-md-7">
                                    <span>{{ $jd_info->branch }}</span>
                                </div>
                            </div> 
                            <div class="form-group row">
                                <label class="control-label text-right col-md-2" for="">银行预留手机号：</label>
                                <div class="col-md-7">
                                    <span>{{ $jd_info->bank_phone }}</span>
                                </div>
                            </div>  
                            <div class="form-group row">
                                <label class="control-label text-right col-md-2" for="">店铺名称：</label>
                                <div class="col-md-7">
                                    <span>{{ $jd_info->store_name }}</span>
                                </div>
                            </div> 
                            <div class="form-group row">
                                <label class="control-label text-right col-md-2" for="">店铺地址：</label>
                                <div class="col-md-7">
                                    <span>{{ $jd_info->store_site }}</span>
                                </div>
                            </div>  
                            <div class="form-group row">
                                <label class="control-label text-right col-md-2" for="">身份证正面照片 ：</label>
                                <div class="col-md-7">
                                    <img src="{{ $jd_info->identity_img_front }}">
                                </div>
                            </div> 
                            <div class="form-group row">
                                <label class="control-label text-right col-md-2" for="">身份证反面照片 ：</label>
                                <div class="col-md-7">
                                    <img src="{{ $jd_info->identity_img_reverse }}">
                                </div>
                            </div> 
                            <div class="form-group row">
                                <label class="control-label text-right col-md-2" for="">手持身份证照片 ：</label>
                                <div class="col-md-7">
                                    <img src="{{ $jd_info->identity_img_person }}">
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="control-label text-right col-md-2" for="">银行卡照片 ：</label>
                                <div class="col-md-7">
                                    <img src="{{ $jd_info->bank_img }}">
                                </div>
                            </div> 
                            <div class="form-group row">
                                <label class="control-label text-right col-md-2" for="">售货机照片 ：</label>
                                <div class="col-md-7">
                                    <img src="{{ $jd_info->machine_img }}">
                                </div>
                            </div> 
                        <form class="needs-validation" method="post" action="{{ route('admin.jds.update', $jd_info->id) }}" novalidate enctype="multipart/form-data">  
                        @csrf
                        @method('PUT')
                            <div class="form-group row">
                                <label class="control-label text-right col-md-2" for="">审核状态：</label>
                                <div class="col-md-7">
                                    <input type="radio" value="0" @if ( old('state', $jd_info->state) == 0) checked @endif class="check" name="state" data-radio="iradio_square-green" id="square-radio-1">
                                    <label class="custom-control-label" for="square-radio-1">未审核</label>
                                    <input type="radio" value="1" @if ( old('state', $jd_info->state) == 1) checked @endif class="check"  name="state" data-radio="iradio_square-green" id="square-radio-2">
                                    <label class="custom-control-label" for="square-radio-2">审核中</label>
                                    <input type="radio" value="2" @if ( old('state', $jd_info->state) == 2) checked @endif class="check" name="state" data-radio="iradio_square-green" id="square-radio-3">
                                    <label class="custom-control-label" for="square-radio-3">审核失败</label>
                                    <input type="radio" value="3" @if ( old('state', $jd_info->state) == 3) checked @endif class="check"  name="state" data-radio="iradio_square-green" id="square-radio-4">
                                    <label class="custom-control-label" for="square-radio-4">审核成功</label>
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="control-label text-right col-md-2">审核失败原因</label>
                                <div class="col-md-7">
                                    <textarea class="form-control" name="opinion" rows="5">{{$jd_info->opinion}}</textarea>
                                </div>
                            </div>
                      	<div class="form-actions">
                            <div class="row">
                                <div class="col-md-8">
                                    <div class="row">
                                        <div class="offset-sm-3 col-md-9">
                                            <button type="submit" class="btn btn-success"> <i class="fa fa-check"></i> 提交</button>
                                            <a href="{{ route('admin.merchants.jdList') }}"><button type="button" class="btn btn-danger"><i class=" fas fa-times"></i> 取消</button></a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
	    </div>
	</div>
</div>
@stop

@section('admin-js')

<!--Custom JavaScript -->
<script src="{{ asset('assets/js/validation.js') }}"></script>
<!-- jQuery file upload -->
<script src="{{ asset('assets/plugins/dropify/dist/js/dropify.min.js') }}"></script>

<script>
//For validation with custom styles
(function() {
  'use strict';
  window.addEventListener('load', function() {
    // Fetch all the forms we want to apply custom Bootstrap validation styles to
    var forms = document.getElementsByClassName('needs-validation');
    // Loop over them and prevent submission
    var validation = Array.prototype.filter.call(forms, function(form) {
      form.addEventListener('submit', function(event) {
        if (form.checkValidity() === false) {
          event.preventDefault();
          event.stopPropagation();
        }
        form.classList.add('was-validated');
      }, false);
    });
  }, false);
  // 头像上传
    var uploadAvatar = $('#upload-avatar').dropify({
        messages: {
            default: '',
            replace: '',
            remove: '删除',
            error: '上传失败'
        }
    });
    uploadAvatar.on('dropify.beforeClear', function(event, element) {
        return confirm("确定删除 \"" + element.file.name + "\" ?");
    });

    uploadAvatar.on('dropify.afterClear', function(event, element) {
        layer.msg('删除成功');
    });

})();
</script>
@stop